import { AuthorFanItem, AuthorItem } from "../types/author"
import { BookItem } from "../types/book"
import { CommonBooleanResult, CommonResult } from "../types/global"
import { http } from "@/utils/http"




/**
 * 获取作者信息
 * @returns 
 */
export const getAuthorInfoAPI = (authorName : string) => {
  return http<AuthorItem>({
    url: '/fanqie/author/getAuthorInfo',
    method: 'GET',
    data: {
      authorName: authorName
    }
  })
}


/**
 * 根据书籍id查询作者信息
 * @param bookId 书籍id
 * @returns 作者信息
 */

export const queryAuthorInfoByBookIdAPI = (bookId : number) => {
  return http<AuthorItem>({
    url: '/fanqie/author/queryAuthorInfoByBookId',
    method: 'GET',
    data: {
      bookId
    }
  })

}



/**
 * 关注作者
 * @param authorId 作者id
 * @returns 
 */

export const addAuthorFanAPI = (authorName : string) => {
  return http<CommonResult>({
    url: '/fanqie/authorFans/addAuthorFan',
    method: 'POST',
    data: {
      authorName
    }
  })
}

/**
 * 取消关注作者
 * @param authorName 作者名
 * @returns 
 */

export const cancelAuthorFanAPI = (authorName : string) => {
  return http<CommonResult>({
    url: '/fanqie/authorFans/cancelAuthorFan',
    method: 'POST',
    data: {
      authorName
    }
  })
}

/**
 * 检查作者是否关注
 * @param authorName 作者名
 * @param bookId 书籍id
 * @returns 
 */

export const checkAuthorFanAPI = (authorName : string) => {
  return http<CommonBooleanResult>({
    url: `/fanqie/authorFans/checkAuthorFan?authorName=${authorName}`,
    method: 'GET',

  })
}



/**
 * 获取作者书籍
 * @param authorName 作者名
 * @returns 
 */
export const getAuthorBooksAPI = (authorName : string) => {
  return http<BookItem[]>({
    url: `/fanqie/authorBook/getAuthorBooks?authorName=${authorName}`,
    method: 'GET',
  })
}

/**
 * 获取作者粉丝
 * @param authorName 作者名
 * @returns 
 */
export const listAuthorFansAPI = (authorName : string) => {
  return http<AuthorFanItem[]>({
    url: `/fanqie/authorFans/listAuthorFans?authorName=${authorName}`,
    method: 'GET',
  })
}